package com.oocl.shopping.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.oocl.shopping.dao.CustomerDao;
import com.oocl.shopping.pojo.Customer;
import com.oocl.shopping.pojo.Order;
import com.oocl.shopping.util.DBUtil;


public class CustomerDaoImpl implements CustomerDao{


	
	@Override
	public int getLastId() {
		int lastId = 0;
	
		return lastId;
	}
	
	

	@Override
	public Customer findCustomer(String name, String pwd) {
		String sql = "select * from CUSTOMERS where name = ? and pwd = ?";
		Connection con = null;
		PreparedStatement pst = null;
		ResultSet rs = null;
		try {
			con=DBUtil.getConnection();
			pst = con.prepareStatement(sql);
			pst.setString(1, name);
			pst.setString(2, pwd);
			rs = pst.executeQuery();
			while(rs.next()){
				Customer cust = new Customer(rs.getString("id"), rs.getString("name"), rs.getString("pwd"));
				return cust;
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally{
			DBUtil.close(null, pst, rs);
		}
		return null;
	}


}
